package com.example.pet.service.impl;

import com.example.pet.beans.MsgInfo;
import com.example.pet.common.Result;
import com.example.pet.mapper.IMsgInfoMapper;
import com.example.pet.mapper.IUserInfoMapper;
import com.example.pet.service.IMsgInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author liukai
 * @version 1.0.0
 * @ClassName MsgInfoServiceImpl.java
 * @Description TODO
 * @createTime 2021年04月28日 11:07:00
 */
@Service
public class MsgInfoServiceImpl implements IMsgInfoService {

    @Autowired
    private IMsgInfoMapper iMsgInfoMapper;

    /**
     * 根据消息发送者和消息接收者查找消息
     * @param sendId
     * @param receiveId
     * @return
     */
    @Override
    public Result findMsgById(String sendId, String receiveId) {
        List<MsgInfo> msgInfoList = iMsgInfoMapper.findMsgById(sendId, receiveId);
        return Result.succ(msgInfoList);
    }

    /**
     * 新增一条消息
     * @param msgInfo
     * @return
     */
    @Override
    public int addMsg(MsgInfo msgInfo) {
        return iMsgInfoMapper.addMsg(msgInfo);
    }
}
